<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>lclei blog</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="lclei" /><meta name="description" content="lclei&#39;s blog." /><meta name="keywords" content="lclei, blog, code" />






<meta name="generator" content="Hugo 0.68.3 with theme even" />


<link rel="canonical" href="http://localhost:1313/" />
  <link href="http://localhost:1313/index.xml" rel="alternate" type="application/rss+xml" title="lclei blog" />
  <link href="http://localhost:1313/index.xml" rel="feed" type="application/rss+xml" title="lclei blog" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">



<link href="/sass/main.min.2e81bbed97b8b282c1aeb57488cc71c8d8c8ec559f3931531bd396bf31e0d4dd.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">


<meta property="og:title" content="lclei blog" />
<meta property="og:description" content="lclei&#39;s blog." />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://localhost:1313/" />
<meta property="og:updated_time" content="2017-08-20T21:38:52+08:00" />
<meta itemprop="name" content="lclei blog">
<meta itemprop="description" content="lclei&#39;s blog."><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="lclei blog"/>
<meta name="twitter:description" content="lclei&#39;s blog."/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo">lclei</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/">
        <li class="mobile-menu-item">Home</li>
      </a><a href="/post/">
        <li class="mobile-menu-item">Archives</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">Tags</li>
      </a><a href="/categories/">
        <li class="mobile-menu-item">Categories</li>
      </a><a href="/about/">
        <li class="mobile-menu-item">About</li>
      </a>
  </ul>

  


</nav>

  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/" class="logo">lclei</a>
</div>





<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="/">Home</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/post/">Archives</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/tags/">Tags</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/categories/">Categories</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/about/">About</a>
      </li>
  </ul>
</nav>

    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <section id="posts" class="posts">
    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/codewar1/">codewar 题1</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2019-12-08 </span>
      
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <h1 id="大数阶乘小数位数">大数，阶乘，小数位数</h1>
<p>在codewar的一道题</p>
<blockquote>
<p>Consider the following numbers (where n! is factorial(n)):</p>
<p>u1 = (1 / 1!) * (1!)
u2 = (1 / 2!) * (1! + 2!)
u3 = (1 / 3!) * (1! + 2! + 3!)
un = (1 / n!) * (1! + 2! + 3! + &hellip; + n!)
Which will win: 1 / n! or (1! + 2! + 3! + &hellip; + n!)?</p>
<p>Are these numbers going to 0 because of 1/n! or to infinity due to the sum of factorials or to another number?</p>
<p>Task</p>
<p>Calculate (1 / n!) * (1! + 2! + 3! + &hellip; + n!) for a given n, where n is an integer greater or equal to 1.</p>
<p>To avoid discussions about rounding, return the result truncated to 6 decimal places, for example:</p>
<p>1.0000989217538616 will be truncated to 1.000098<br>
1.2125000000000001 will be truncated to 1.2125<br>
Remark</p>
<p>Keep in mind that factorials grow rather rapidly, and you need to handle large inputs.</p>
</blockquote>
    </div>
    <div class="read-more">
      <a href="/post/codewar1/" class="read-more-link">Read more...</a>
    </div>
  </div>
</article>

    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/codewar2/">CodeWar 题2</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2019-12-08 </span>
      
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <h1 id="codewardoublecola">CodeWar::DoubleCola</h1>
<p>CodeWar上的一道题</p>
<blockquote>
<p>Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a &ldquo;Double Cola&rdquo; drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on.</p>
<p>For example, Penny drinks the third can of cola and the queue will look like this:</p>
<blockquote>
<p>Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny</p>
</blockquote>
<p>Write a program that will return the name of the person who will drink the n-th cola.</p>
</blockquote>
    </div>
    <div class="read-more">
      <a href="/post/codewar2/" class="read-more-link">Read more...</a>
    </div>
  </div>
</article>

    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/codewar3/">codewar 题3</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2019-12-08 </span>
      
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <h1 id="codewarintervals">CodeWar::Intervals</h1>
<blockquote>
<p>Write a function called sumIntervals/sum_intervals() that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once.</p>
<p>Intervals</p>
<p>Intervals are represented by a pair of integers in the form of an array. The first value of the interval will always be less than the second value. Interval example: [1, 5] is an interval from 1 to 5. The length of this interval is 4.</p>
<p>Overlapping Intervals</p>
<p>List containing overlapping intervals:</p>
<blockquote>
<p>[
[1,4],
[7, 10],
[3, 5]
]</p>
</blockquote>
<p>The sum of the lengths of these intervals is 7. Since [1, 4] and [3, 5] overlap, we can treat the interval as [1, 5], which has a length of 4.</p>
<p>Examples:</p>
<blockquote>
<p>sum_intervals( {
{1,2},
{6, 10},
{11, 15}
} ); // =&gt; 9</p>
</blockquote>
<blockquote>
<p>sum_intervals( {
{1,4},
{7, 10},
{3, 5}
} ); // =&gt; 7</p>
</blockquote>
<blockquote>
<p>sum_intervals( {
{1,5},
{10, 20},
{1, 6},
{16, 19},
{5, 11}
} ); // =&gt; 19</p>
</blockquote>
</blockquote>
    </div>
    <div class="read-more">
      <a href="/post/codewar3/" class="read-more-link">Read more...</a>
    </div>
  </div>
</article>

    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/codewar/">CodeWars</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2019-12-08 </span>
      
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      codewars 感觉题比leetcode的有趣，邀请链接 www.codewars.com/r/zuBfBg
    </div>
    <div class="read-more">
      <a href="/post/codewar/" class="read-more-link">Read more...</a>
    </div>
  </div>
</article>

    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/docker1/">docker1</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2019-12-08 </span>
      
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <h1 id="初探docker">初探docker</h1>
<p>我的centos挂掉了，折腾了一两天没有成效，暂时不做他想，可能需要重装了吧。之前在win10上用VMware，老破电脑太卡，机缘巧合之下，我了解到docker是轻量级的虚拟机，来试一下。</p>
    </div>
    <div class="read-more">
      <a href="/post/docker1/" class="read-more-link">Read more...</a>
    </div>
  </div>
</article>

    </section>
  
  <nav class="pagination">
    <a class="prev" href="/page/4/">
        <i class="iconfont icon-left"></i>
        <span class="prev-text">Prev</span>
      </a>
    <a class="next" href="/page/6/">
        <span class="next-text">Next</span>
        <i class="iconfont icon-right"></i>
      </a>
  </nav>
        </div>
        

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
      <a href="mailto:lclei@mail.ustc.edu.cn" class="iconfont icon-email" title="email"></a>
      <a href="https://gitee.com/lclei" class="iconfont icon-gitee" title="gitee"></a>
      <a href="https://gitee.com/lclei" class="iconfont icon-github" title="github"></a>
  <a href="http://localhost:1313/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="power-by">
    Powered by <a class="hexo-link" href="https://gohugo.io">Hugo</a>
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    Theme - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>

  

  <span class="copyright-year">
    &copy; 
    2018 - 
    2022<span class="heart"><i class="iconfont icon-heart"></i></span><span>lclei</span>
  </span>
</div>

    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>



<script type="text/javascript" src="/js/main.min.c12618f9a600c40bd024996677e951e64d3487006775aeb22e200c990006c5c7.js"></script>








</body>
</html>
